Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

284
Views
Vue and firebase project giving mean error of Property or method "state " is not defined on the instance but referenced during render
<template>
<div>
  <div class="view login" v-if="state.username === '' || state.username === null">
    <form class="login-form" @submit.prevent="Login">
      <div class="form-inner">
    <h1>Login to FireChat</h1>
       <label for="username">Username</label>
       <input type="text" v-model="inputUsername" placeholder="Please enter your username...">
       <input type="submit" value="Login">
    </div>
    </form>

  </div>

  <div class="view chat" v-else>
    <h1>Chat View</h1>
  </div>
  
</div>
</template>

<script>
import { reactive, onMounted, ref } from 'vue';
import db from './db';


export default {
  setup () {
    const inputUsername = ref("");
    const state = reactive({
      username: "",
      messages: []
    });
    
    const Login = () => {
      if (inputUsername.value != "" || inputUsername.value != null) {
        state.username = inputUsername.value;
        inputUsername.value = "";
      }
    }

     return {
      inputUsername,
      Login,
      state
    }
  }
}
</script>

I cant seem to figure out where am getting it wrong when state is defined I believe. the screen shows nothing. this code is literally from a tutorial i watched and exactly this worked even after getting code from the tutorial github repo it still shows this error

Property or method "state " is not defined on the instance but referenced during render.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Never used vue but i noticed that your script declares state however your script is loaded in the document after the div is because of the order you placed it.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!